package strategy.improve;

/**
 * @Author liangliangzhao
 * @data 2023/4/21 11:21
 */

public abstract class Duck {
    public String name;
    FlyBehavior flyBehavior;//属性 策略接口
    public Duck(){}
    public abstract void display();//显示鸭子信息
    public void quack(){
        System.out.println("鸭子");
    }
    public void swim(){
        System.out.println("鸭子会游泳");
    }
    public void fly(){
        if(flyBehavior != null){
            flyBehavior.fly(name);
        }
    }
    public void setFlyBehavior(FlyBehavior flyBehavior) {
        this.flyBehavior = flyBehavior;
    }
}
